package com.bolt.admin.common.base;

import com.bolt.common.security.DesUtil;

import javax.persistence.AttributeConverter;

/**
 * Created by Administrator on 2020/10/14.
 */
public class EncryptConverter implements AttributeConverter <String, String> {


    /**
     * 加密.
     */
    @Override
    public String convertToDatabaseColumn(String text) {
        try {
            String des = DesUtil.desEncrypt(text);
            return des;
        } catch (Exception ex) {
            return text;
        }
    }

    /**
     * 解密.
     */
    @Override
    public String convertToEntityAttribute(String text) {
        try {
            String des = DesUtil.desDecrypt(text);
            return des;
        } catch (Exception ex) {
            return text;
        }
    }

}

 